layui.config({
    base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        $ = layui.jquery;

    // 监听是否原创的单选按钮
    form.on('radio(fromType)', function(data){
        // data {"elem":{},"value":"1","othis":{"0":{"jQuery191047573129280968063":35},"length":1}}
        if(data){
            var $ori = $("#originalAuthor");
            var $reprint = $("#reprintAuthor");

            if(data.value == "0"){
                $ori.show();
                $reprint.hide();
                // 只能这样设置,如果还有隐藏域,thymeleaf会当做类似checkbox的多个值传入
                $("#reprintAuthor > input").val($ori.children("input").val());
            }else{
                $reprint.show();// 给这个input上直接绑定值
                $("#reprintAuthor > input").val("");
                $ori.hide();
            }
        }
    });

    initFroalaEditor();
    function initFroalaEditor() {
        $('#froalaEditor').on('editable.initialized', function (e, editor) {
            var $content = $("#froalaEditor").find("div[contenteditable='true']");
            $content.css("height","100%").attr("contenteditable","false");
            editor.setHTML($("#contentH").val());
        }).editable({
            inlineMode: false,
            buttons: []
        })
    }
})
